}
static GtkIconInfo *
-choose_icon (GtkIconTheme *icon_theme,
- const gchar *icon_names[],
- gint size,
- gint scale,
- GtkIconLookupFlags flags)
+real_choose_icon (GtkIconTheme *icon_theme,
+ const gchar *icon_names[],
+ gint size,
+ gint scale,
+ GtkIconLookupFlags flags)
{
GtkIconThemePrivate *priv;
GList *l;
return icon_info;
}
+static GtkIconInfo *
+choose_icon (GtkIconTheme *icon_theme,
+ const gchar *icon_names[],
+ gint size,
+ gint scale,
+ GtkIconLookupFlags flags)
+{
+ gboolean has_regular = FALSE, has_symbolic = FALSE;
+ GtkIconInfo *icon_info;
+ gchar **new_names;
+ guint i;
+
+ for (i = 0; icon_names[i]; i++)
+ {
+ if (g_str_has_suffix (icon_names[i], "-symbolic"))
+ has_symbolic = TRUE;
+ else
+ has_regular = TRUE;
+ }
+
+ if ((flags & GTK_ICON_LOOKUP_FORCE_REGULAR) && has_symbolic)
+ {
+ new_names = g_new0 (gchar *, i + 1);
+ for (i = 0; icon_names[i]; i++)
+ {
+ if (g_str_has_suffix (icon_names[i], "-symbolic"))
+ new_names[i] = g_strndup (icon_names[i], strlen (icon_names[i]) - strlen ("-symbolic"));
+ else
+ new_names[i] = g_strdup (icon_names[i]);
+ }
+ }
+ else if ((flags & GTK_ICON_LOOKUP_FORCE_SYMBOLIC) && has_regular)
+ {
+ new_names = g_new0 (gchar *, i + 1);
+ for (i = 0; icon_names[i]; i++)
+ {
+ if (!g_str_has_suffix (icon_names[i], "-symbolic"))
+ new_names[i] = g_strconcat (icon_names[i], "-symbolic", NULL);
+ else
+ new_names[i] = g_strdup (icon_names[i]);
+ }
+ }
+ else
+ {
+ new_names = NULL;
+ }
+
+ icon_info = real_choose_icon (icon_theme,
+ new_names ? (const gchar **) new_names : icon_names,
+ size,
+ scale,
+ flags & ~(GTK_ICON_LOOKUP_FORCE_REGULAR | GTK_ICON_LOOKUP_FORCE_SYMBOLIC));
+
+ if (new_names)
+ g_strfreev (new_names);
+
+ return icon_info;
+}
+
/**
* gtk_icon_theme_lookup_icon:
* fallback, see gtk_icon_theme_choose_icon(). Since 2.12.
* @GTK_ICON_LOOKUP_FORCE_SIZE: Always get the icon scaled to the
* requested size. Since 2.14.
+ * @GTK_ICON_LOOKUP_FORCE_REGULAR: Always load regular icons, even when
+ * symbolic icon names are given. Since 3.14.
+ * @GTK_ICON_LOOKUP_FORCE_SYMBOLIC: Always load symbolic icons, even when
+ * regular icon names are given. Since 3.14.
*
* Used to specify options for gtk_icon_theme_lookup_icon()
*/
GTK_ICON_LOOKUP_FORCE_SVG = 1 << 1,
GTK_ICON_LOOKUP_USE_BUILTIN = 1 << 2,
GTK_ICON_LOOKUP_GENERIC_FALLBACK = 1 << 3,
- GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 4
+ GTK_ICON_LOOKUP_FORCE_SIZE = 1 << 4,
+ GTK_ICON_LOOKUP_FORCE_REGULAR = 1 << 5,
+ GTK_ICON_LOOKUP_FORCE_SYMBOLIC = 1 << 6
} GtkIconLookupFlags;
/**